home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
-
- REBOOT.CPP - Performs a warm boot of computer with password checking.
-
- Copyright (C) 1992 Joe L Chavez.
- Permission is granted to any individual or institution to use, copy, or
- redistribute this software so long as all of the original files are included
- unmodified, that it is not sold for profit, and that this copyright notice
- is retained.
-
- I have include the source code so that your password can be encoded into
- the program and recompiled. This is the safest way.
-
-
- ***************************************************************************/
-
- #include <dos.h>
- #include <ctype.h>
- #include <string.h>
- #include <conio.h>
- #include <fstream.h>
-
- #define CONTINUE 1
-
- // Control Break handler that intercepts and does nothing
- // with a control-break
-
- int c_break(void)
- {
- return (CONTINUE);
- }
-
-
- int main()
- {
- ctrlbrk(c_break);
-
-
- // ************** Get the current date and time and write to
- // the file boot.log with appending.
- // If the file does not exist then no output is written.
-
- ofstream ofile;
-
- ofile.open("boot.log", ios::out|ios::ate);
-
- if(ofile) {
- struct dosdate_t today;
- struct dostime_t now;
-
- _dos_getdate(&today);
- _dos_gettime(&now);
- ofile << today.year << "/"
- << (int)today.month << "/"
- << (int)today.day << " ";
- ofile << (int)now.hour << ":"
- << (int)now.minute << ":"
- << (int)now.second << ":"
- << (int)now.hsecond << "\n";
-
- ofile.close();
- }
-
- clrscr();
-
- char *password;
-
- // get the password from the user up to 8 characters
- password = getpass("Enter password:");
-
- // convert to upper case for comparison
- int length = strlen(password);
- for (int i=0; i<length; i++)
- {
- password[i] = toupper(password[i]);
- }
-
-
- // check the password, change the value in the quotes for new password
- if(!strcmp("PASSWORD", password) == 0) {
-
- // The location of the reset flag
- int far *Reset_Flag = (int far *)0x0472L;
-
- // this value indicates a warm boot is to be performed
- Reset_Flag[0] = 0x1234;
-
- // here it is the BASM code to perform the boot
- asm {
- db 0xea
- dw 0x00
- dw 0xffff
- }
- }
-
- return 0;
-
- }
-
-